#ifndef CTLPARSER_HH_
# define CTLPARSER_HH_

///
/// \file CTLParser.hh
/// \brief Definition of the parser.
/// \author Coddy Levi, Sylvain Lobry
/// \version 1.0
///
/// Definition of the class implementing the formula parser and definition of
/// the class implementing the resulting AST.
///

# include "CTLLexer.hh"
# include <iostream>


///
/// \class AST
/// \brief The class that implements the AST.
///
class AST
{
private:
  ///
  /// The value of the current node
  ///
  symbols		value_;

  ///
  /// The value of the current node in case of a variable.
  std::string		var_value_;

  ///
  /// The array of the sons.
  ///
  AST**			sons_;

  ///
  /// The number of sons.
  ///
  unsigned		nb_sons_;

public:
  ///
  /// The main constructor.
  ///
  AST (symbols		value);

  ///
  /// The constructor in the case of a variable.
  ///
  AST (std::string	value);

  ///
  /// \brief An accessor to the ith son.
  ///
  /// \param[in]	i The number of the son to be returned.
  /// \return		A pointer to the son, or null if i is out of bound.
  ///
  AST*
  getIthSon (unsigned	i);

  ///
  /// \brief Set the array of sons.
  ///
  /// \param[in]	sons The array of sons.
  /// \param[in]	nb The size of the array.
  ///
  void
  setSons (AST**	sons,
	   unsigned	nb);

  ///
  /// \brief Print the AST
  ///
  /// \param[in]	offset The number of spaces before the print
  ///			(i.e. the layer of the node in the tree).
  void
  print (unsigned offset);

  ///
  /// \brief return the value of the node.
  ///
  /// \return		The token.
  ///
  symbols
  getValue ();

  ///
  /// \brief return the value of the node in case of a variable.
  ///
  /// \return		The variable. Empty string if the node does not contain
  ///			a variable.
  ///
  std::string
  getVariable ();
};

///
/// \fn AST* parseCTL (CTLLexer &lex)
/// \brief The function that construct the AST.
///
/// \param[in]		lex The lexer that contains the formula.
/// \return		The resulting AST.
///
AST*
parseCTL (CTLLexer &lex);


///
/// \fn AST** parseNargs (CTLLexer &lex, unsigned argc)
/// \brief The function that parse the arguments for a given token.
///
/// \param[in]		lex The lexer that contains the formula.
/// \param[in]		argc The number of arguments to be checked.
/// \reuslt		The sons of the current node.
///
AST**
parseNargs (CTLLexer &lex,
	    unsigned argc);

#endif /* !CTLPARSER_HH_ */
